package org.kotboot.kit;/**
 * Created by jisong.sun on 2017/9/14.
 */

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageException;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;

/**
 * jisong.sun 2017/9/14 10:34
 */
public class KMap extends JSONObject {

    public String getStringSafe(String key){
        String str = this.getString(key);
        return str == null?"":str;
    }

    public void startPage(){
        String orderBy = this.getString("orderBy");
        if(null != orderBy && !RegKit.orderBy.matcher(orderBy).find()){
            throw new PageException("需要正确的排序格式！");
        }
        PageHelper.startPage(this);
    }

    public void orderBy(String orderBy){
        PageHelper.orderBy(orderBy);
    }
}
